package com.cndw.kungfu.dao;

import java.util.Map;

import com.cndw.dao.jade.annotation.DAO;
import com.cndw.dao.jade.annotation.KeyColumnOfMap;
import com.cndw.dao.jade.annotation.SQL;
import com.cndw.dao.jade.annotation.SQLParam;
import com.cndw.kungfu.domain.Skill;

@DAO
public interface SkillDao {

	public static final String TABLE = "kf_player_skill";
	
	public static final String FIELDS = "playerId,skillLibId,level,skillId,position,addTime";
	
	
	@SQL("REPLACE INTO "+TABLE+" ("+FIELDS+") VALUES(:p.playerId,:p.skillLibId,:p.level,:p.skillId,:p.position,:p.addTime)")
	public int insert(@SQLParam("p") Skill Skill);
	
	//@SQL("REPLACE INTO "+TABLE+" ("+FIELDS+") VALUES(:p.playerId,:p.skillId,:p.position,:p.addTime")
	//public int replace(@SQLParam("p") Skill skill);
	
	@SQL("select "+FIELDS+" from "+TABLE+" where playerId=:playerId  ")
	@KeyColumnOfMap("skillLibId")
	public Map<Integer, Skill> getByPlayerId(@SQLParam("playerId") long playerId);
	
	
	@SQL("update  "+TABLE+"  set position=:position where playerId=:playerId and skillLibId=:skillLibId ")
	public int update(@SQLParam("position") int position,
					  @SQLParam("playerId") long playerId,
					  @SQLParam("skillLibId") int skillLibId);
	
}
